package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.TkaoqinForm;
import com.sample.javabean.Tkaoqin;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class TkaoqinAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(TkaoqinAction.class);
    	 	private Pager<Tkaoqin> pageList;
    	 	private Integer id;
    	 	private Tkaoqin tkaoqin=new Tkaoqin();
    	 	private TkaoqinForm tkaoqinForm=new TkaoqinForm();
    	 	
    	 	
    	 	/**
    	 	 * 教师信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputTkaoqin()throws Exception{
    	 		
    	 		return "inputTkaoqin";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加考勤信息");
    	 			if(tkaoqinForm!=null){
    	 				Tkaoqin tkaoqin =new Tkaoqin();
    	 				 //将tkaoqinForm中的属性值一一对应tkaoqin的对应属性
    	 				tkaoqin.setTname(tkaoqinForm.getTname());
    	 				tkaoqin.setChuqin(tkaoqinForm.getChuqin());
    	 				tkaoqin.setDay(tkaoqinForm.getDay());
    	 			   //调用方法
    	 				tkaoqin.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputTkaoqin";
    	 	}
    	 	
    	 	public String list()throws Exception{
    	 		Tkaoqin tkaoqinModel =new Tkaoqin();
    	 		pageList =tkaoqinModel.list(page,size,tkaoqinForm);
    	 		return "listTkaoqin";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(tkaoqinForm!=null){
    	 				tkaoqin.setId(id);
    	 				tkaoqin.delTkaoqin();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editTkaoqin()throws Exception{
    	 		log.info("修改考勤信息");
    	 		try{
    	 			tkaoqin.setId(id);
    	 			tkaoqin.load();
    	 			return "editTkaoqin";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		log.info("修改考勤信息");
    	 		try{
    	 			
    	 			if(tkaoqinForm!=null){
    	 			                     
    	 				 //将persinfoForm中的属性值一一对应persinfo的对应属性
    	 				tkaoqin.setId(tkaoqinForm.getId());
    	 				tkaoqin.setTname(tkaoqinForm.getTname());
    	 				tkaoqin.setChuqin(tkaoqinForm.getChuqin());
    	 				tkaoqin.setDay(tkaoqinForm.getDay());
    	 				
    	 				tkaoqin.editTkaoqin();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Tkaoqin> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Tkaoqin> pageList) {
				this.pageList = pageList;
			}
			public Integer getId() {
				return id;
			}
			public void setId(Integer id) {
				this.id = id;
			}
			public Tkaoqin getTkaoqin() {
				return tkaoqin;
			}
			public void setTkaoqin(Tkaoqin tkaoqin) {
				this.tkaoqin = tkaoqin;
			}
			public TkaoqinForm getTkaoqinForm() {
				return tkaoqinForm;
			}
			public void setTkaoqinForm(TkaoqinForm tkaoqinForm) {
				this.tkaoqinForm = tkaoqinForm;
			}
			public static Log getLog() {
				return log;
			}
			
}
